package com.epam.chenjo.ms.salary.dao.impl;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;
import org.yaml.snakeyaml.Yaml;

import com.epam.chenjo.ms.salary.dao.SalaryDao;
import com.epam.chenjo.ms.salary.model.SalaryDetails;

@Component("d")
public class DummySalaryDao implements SalaryDao {

	@SuppressWarnings("unchecked")
	@Override
	public List<SalaryDetails> fetchSalaries(String empId) {
		Yaml y = new Yaml();
		Map<String, SalaryDetails> map = (Map<String, SalaryDetails>) y
				.load(DummySalaryDao.class.getResourceAsStream("/salary.yml"));
		if (map.keySet().contains(empId)) {
			return Arrays.asList(map.get(empId));
		}

		return new ArrayList();
	}
}
